package com.eurasia.assignment.infrastructure.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.eurasia.assignment.domain.User;
import com.eurasia.assignment.domain.UserRole;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    Optional<User> findByUsername(String username);
    boolean existsByUsername(String username);
    
    // 根据角色查询用户
    List<User> findByRole(UserRole role);
    
    // 根据角色和真实姓名模糊查询
    List<User> findByRoleAndRealNameContaining(UserRole role, String realName);
}